package com.zhangmeng.online.exam.ui.components;

import javafx.beans.property.SimpleStringProperty;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;

/**
 * @author zm
 * @date 2025/3/19 17:03
 * @version: 1.0
 */
public class PaperSearchComponent extends HBox {


    public enum SearchType {
        QUESTION_NAME,//问题搜索
        User_NAME;//用户搜索

    }

    private SearchType searchType;

    public SearchType getSearchType() {
        return searchType;
    }

    public void setSearchType(SearchType searchType) {
        this.searchType = searchType;
    }

    private Button searchButton;

    private SimpleStringProperty questionName = new SimpleStringProperty();

    public PaperSearchComponent(double spacing, SearchType searchType) {
        super();
        this.searchType = searchType;

        this.setSpacing(spacing);
        Label label = null;
        if (searchType == SearchType.QUESTION_NAME) {
            label =  new Label("问题名称：");
        } else {
            label =  new Label("用户名称：");
        }


        label.setPadding(new Insets(5, 0, 0, 0));
        TextField questionName = new TextField();

        questionName.textProperty().bindBidirectional(this.questionName);

        searchButton = new Button("搜索");
        this.getChildren().add(label);
        this.getChildren().add(questionName);
        this.getChildren().add(searchButton);

    }

    public Button getSearchButton() {
        return searchButton;
    }

    public void setSearchButton(Button searchButton) {
        this.searchButton = searchButton;
    }

    public SimpleStringProperty getQuestionName() {
        return questionName;
    }

    public void setQuestionName(SimpleStringProperty questionName) {
        this.questionName = questionName;
    }
}
